from selenium.webdriver.common.by import By

from base.base_page import BasePage


class page_login_object(BasePage):

    fy=(By.XPATH,'//img[@onclick="selectFy();"]')
    fymc=(By.XPATH,'//span[text()="江苏省南京市中级人民法院"]')
    username=(By.ID,'username')
    password=(By.ID,'password')
    dl=(By.ID,'dl')
    def selecFy(self):
        self.click(page_login_object.fy)
        current_window= self.get_current_window()
        for handl in self.get_allwindows():
            if handl != current_window:
                self.goto_otherwindow(handl)
                self.driver.implicitly_wait(2)
                self.double_click(page_login_object.fymc)

        self.goto_otherwindow(current_window)

    def login(self):
        # self.locater_element(page_login_object.username)
        self.send_keys(page_login_object.username,'0001')
        self.send_keys(page_login_object.password,'123')
        self.click(page_login_object.dl)
